package com.apes.auto.car.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * @ClassName CarBrand
 * @Description TODO
 * @Author pengyb
 * @Date 2019/7/9 14:22
 * @Version 1.0
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = CarBrand.CONST_TABLE_NAME,indexes = {
        @Index(columnList = "name")
})
public class CarBrand extends Model {
    public static final String CONST_TABLE_NAME = "dc_car_brand";
    @Id
    @Column(name = "id", length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "品牌")
    private String id;

    @Column(name = "code", length = 32)
    @Comment("品牌编码")
    private String code;

    @Column(name = "name", length = 32)
    @Comment("品牌名称")
    private String name;

    @Column(name = "valid", nullable = false, columnDefinition = "number(1,0) default 1")
    @Comment("有效标记")
    private boolean valid = true; //有效

    @Column(name = "carCategory", length = 8)
    @Comment("类别")
    private String carCategory;//类别(carCategory)(国产;进口;合资)

}
